#include <stdio.h>
#include <assert.h>
void main(int argc, char *argv[])
{
	FILE *input, *output;
	char readbuf[1024];
	
	if (argc != 3){
		printf("Usage: popen <program> <file>");
		return;
	}
	
	input = fopen(argv[2], "r");
	assert(input != NULL);
	
	output = popen(argv[1], "w");
	assert(output != NULL);
	
	while(feof(input) == 0){
		fread(readbuf, 1, sizeof(readbuf), input);
		fputs(readbuf, output);
	}
	
	fclose(input);
	pclose(output);
}
